We create sealed class when we want to restrict or prevent the class to be inherited. Sealed modifier is used to prevent derivation from a class. If we try to specify a sealed class as base class then a compile-time error occurs.
If we try to inherit sealed class then following error well be occure
class MyDerivedC: SealedClass {} // Error
The result is an error message:
'MyDerivedC' cannot inherit from sealed class 'SealedClass'.
Liked By
Write Answer
What are sealed classes in C#?
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
18-Mar-2018We create sealed class when we want to restrict or prevent the class to be inherited. Sealed modifier is used to prevent derivation from a class. If we try to specify a sealed class as base class then a compile-time error occurs.
If we try to inherit sealed class then following error well be occure
class MyDerivedC: SealedClass {} // Error
The result is an error message:
'MyDerivedC' cannot inherit from sealed class 'SealedClass'.